package com.me.jingdongshop.ui.activity;

import android.os.Message;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.me.common.base.BaseActivity;
import com.me.common.ui.BaseAdapterRV;
import com.me.jingdongshop.R;
import com.me.jingdongshop.model.bean.MessageBean;
import com.me.jingdongshop.ui.adapter.MessageAdapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by CJC on 2017/5/8.
 */

public class MessageCenterActivity extends BaseActivity {
    private int[] messageFhotoArr = new int[]{R.drawable.message01, R.drawable.message02, R.drawable.message03, R.drawable.message04, R.drawable.message05,
            R.drawable.message06, R.drawable.message07, R.drawable.message08, R.drawable.message09, R.drawable.message10,};
    private String[] titleArr = new String[]{"小米旗舰店", "东东客服", "消息提醒", "互动消息", "商品物流信息", "优惠促销", "系统提醒", "我的资产"};
    private String[] contentArr = new String[]{"你购买的商品（小米手环）已发货，请耐心等候", "你入手的宝贝被社区推荐了，快去看看呗",
            "图书每满49减15，限时秒杀，快来抢购哦！！！！", "你昨日收到一张优惠券，优惠额度20.0元",
            "你的订单F1029384756已完成，感谢您对东东的支持", "【链接】我分享了一款宝贝，速速来看吧",
            "您还要两份订单尚未完成，完成订单可以获得豆豆奖励哦！！", "请对我的服务进行评价，非常感谢"};

    private List<MessageBean> msgList;

    private ImageView ivMessageCenterBack;
    private RecyclerView rvMessageCenter;

    @Override
    public int getLayoutRes() {
        return R.layout.search_message_center;
    }

    @Override
    public void initView() {
        ivMessageCenterBack = (ImageView) findViewById(R.id.iv_message_center_back);
        rvMessageCenter = (RecyclerView) findViewById(R.id.rv_message_center);
        ivMessageCenterBack.setOnClickListener(this);


    }

    @Override
    public void initListener() {

    }

    @Override
    public void initData() {

        msgList = new ArrayList<>();

        for (int i = 0; i < 50; i++) {
            MessageBean msg = new MessageBean();
            msg.setPhoto(messageFhotoArr[new Random().nextInt(messageFhotoArr.length)]);
            msg.setTitle(titleArr[new Random().nextInt(titleArr.length)]);
            msg.setContent(contentArr[new Random().nextInt(contentArr.length)]);
            msgList.add(msg);
        }

        LinearLayoutManager manager = new LinearLayoutManager(this);
        rvMessageCenter.setLayoutManager(manager);
        rvMessageCenter.setAdapter(new MessageAdapter(this,msgList));



    }

    @Override
    public void onClick(View v, int id) {
        switch (v.getId()){
            case R.id.iv_message_center_back:
                finish();
                break;
        }

    }

    @Override
    public void onHttpSuccess(int reqType, Message msg) {

    }

    @Override
    public void onHttpError(int reqType, String error) {

    }
}
